/*
 * leerXML
 * 
 * Version 
 *
 * 27/09/2013
 * 
 * Licencia
 */
package proyecto2.logica;

import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;

public class LectorXML {

    org.w3c.dom.Document doc;

    public LectorXML(File url) {
        parseXML(url);
    }

    private void parseXML(File url) {
        DocumentBuilderFactory docBuilderFactory;
        DocumentBuilder docBuilder;
        try {
            docBuilderFactory = DocumentBuilderFactory.newInstance();
            docBuilder = docBuilderFactory.newDocumentBuilder();
            doc = docBuilder.parse(url);
            doc.getDocumentElement().normalize();
           // printNote(doc.getChildNodes());
        } catch (ParserConfigurationException | SAXException | IOException exc) {
            System.err.println("Error leyendo xml. Metodo parseXML. " + exc.toString());
        }
    }

    //devuelve un DOM del xml leido
    public org.w3c.dom.Document getDocument() {
        return doc;
    }

    
}
